package com.example.fly.pushdemo.smack.extension;

import org.jivesoftware.smack.packet.PacketExtension;

/**
 * Created by fly on 2017/4/13.
 */

public class ErrorExt implements PacketExtension {

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    private int code;
    private String errorMsg;


    @Override
    public String getElementName() {
        return "error";
    }

    @Override
    public String getNamespace() {
        return "";
    }

    @Override
    public String toXML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<");
        sb.append(getElementName());
        sb.append(" code = \"" + getCode() + "\"");
        sb.append(">");

        sb.append(getErrorMsg());


        sb.append("</");
        sb.append(getElementName());
        sb.append(">");
        return sb.toString();
    }
}
